<!doctype html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>角色管理</title>
</head>
<body>

<form id="createForm" th:action="@{/system/role/create}">
    <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
    <label for="name">角色名称</label>
    <input id="name" name="name">
    <input type="button" th:value="提交" onclick="sub()">
</form>

</body>
<script src="../static/lib/jquery-3.4.0.js" th:src="@{/lib/jquery-3.4.0.js}"></script>
<script th:inline="javascript">

    function sub() {
        var data = $('#createForm').serialize();
        $.ajax({
            type: 'POST',
            url: '/system/role/create',
            data: data,
            success: function (result) {
                if (result.status === 20000) {
                    window.location.href = './index';
                } else {
                    alert(result.message);
                }
            }
        })
    }


</script>
</html>
